package club.janna.springboot.study.controller;

import club.janna.springboot.study.domain.User;
import club.janna.springboot.study.repository.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserMapper userMapper;

    @RequestMapping("list")
    public List<User> list() {
        return userMapper.list();
    }

    @RequestMapping("update")
    public User update(long id, String password) {
        userMapper.update(id, password);
        return userMapper.getById(id);
    }
}
